-- check_run_tree_action
--
local import = import
---@type behavior_ret
local bret = import('bt/bt_plugin/behavior3/behavior_ret')
---@type TREE_TYPE_CONFIG
local TREE_TYPE_CONFIG = import('bt/custom_node/enum_type_cfg/TREE_TYPE_CONFIG')
local TYPE_OPTIONS = TREE_TYPE_CONFIG.TYPE_OPTIONS
local RUN_TREE_DATA_KEY = TREE_TYPE_CONFIG.RUN_TREE_DATA_KEY
local M = {
    name = "check_run_tree_action",
    type = "Condition",
    desc = "检查当前行为是否为指定类型",
    args = {
        {
            name = "actionType",
            type = "enum",
            desc = "行为",
            options = TYPE_OPTIONS
        },
    },
}

function M.run(node, env, value)
    local actionType = node.args.actionType
    local data = env[RUN_TREE_DATA_KEY]
    if data and data.actionType == actionType then
        return bret.SUCCESS
    end
    return bret.FAIL
end

return M
